package live.ifox.stage;

import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import java.util.List;
import java.util.Map;

import live.ifox.helper.AdapterHelper;
import live.ifox.helper.PackageHelper;

public class AboutActivity extends AppCompatActivity {
    ListView listView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about);

        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(true);
            actionBar.setTitle(R.string.about);
        }
        listView = findViewById(R.id.listView);
        PackageHelper packageHelper = new PackageHelper(this);
        List<Map<String, Object>> infoModel = packageHelper.getModel();
        SimpleAdapter adapter = AdapterHelper.getTableAdapter(this,
                infoModel, new String[]{"label", "detail"});
        listView.setAdapter(adapter);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            finish();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}
